const mysql = require('mysql');
const DB_CONF = require('./db');
let connection = mysql.createConnection(DB_CONF);
connection.connect();

function exec(sql) {
  return new Promise((resolve, reject) => {
    connection.query(sql, (err, results, fields) => {
      if (err) {
        reject(err);
      } else {
        resolve(results);
      }
    });
  });
}

module.exports = exec;
